<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		
	</body>
	<script type="text/javascript">
		/* 标签语句 continue--break*/
			var array = [1,2,3,4,5,undefined,7,8,9];
			var i = 0,m = 0,sum = 0;
			//continue
			jumpTo1:for(var n = 0;n<4;n++){
				console.log("n-:"+n+"---"+"i-:"+i);
				if(i==2){
					continue jumpTo1;//会在此跳出循环,但会继续循环
				}
				i++;
			}
			console.log("--------------");
			//break
			jumpTo2:for(var n = 0;n<4;n++){//此语句的作用域
				console.log("n-:"+n+"---"+"m-:"+m);
				if(m==2){
					break jumpTo2;//会在此跳出循环,但会停止循环
				}
				m++;
			}
			
			i = 0,m = 0;
			jumpTo3:while(i<=4){
				console.log("i-:"+i+"---"+"m-:"+m);
				i++;
				if(m==2){
					//continue jumpTo4;		// =>报错: Undefined label 'jumpTo4'
					console.log("--------------")
					jumpTo4:for(var n = 0;n<4;n++){
						console.log("n-:"+n+"---"+"m-:"+m);
						if(m==2){
							//continue jumpTo3;		//跳转作用域只能向外跳转
							break jumpTo3;
						}
					}
				}
				m++;
			}
			
			for(var n=0;n<11;n++){
				if(!array[n]) continue; //不存在目标是会跳过本次循环,有嵌套的循环时效果比较明显
				console.log(sum += array[n])
			}
			
			jumpTo5:if(m==2){
				console.log("if的break标签语句");
				//continue jumpTo5;		//continue标签语不可以去定义if
				//break jumpTo5;		//break标签语句同样可以去定义if
			}
			
		/* break语句 */	
			
			
	</script>
</html>
